const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')

module.exports = env => {

	return {
		entry:{
			index:'./app/js/index.js',
			// getData:'./app/js/getData.js'
		},
		output:{
			path:path.resolve(__dirname,'dist'),
			filename: '[name].min.js'
		},
		module: {
			rules: [{
				test:/\.css$/,
				use: ['style-loader','css-loader']
			},{
				test:/\.js$/,
				include: path.resolve(__dirname,'app/js'),
				use: {
					loader: 'babel-loader',
					// options: {
					// 	presets: ['@babel/preset-env'],
					// 	// plugins: ['@babel/transform-runtime']
					// }
				}
			}]
		},
		plugins:[
			new CleanWebpackPlugin(['dist']),
			new HtmlWebpackPlugin({
				template:'./app/view/index.html',
				filename:'./index.html',
				inject:path.resolve(__dirname,'dist/index.min.js')
			}),
			// new UglifyJSPlugin()
		]
	}
}
